﻿using System;
using System.Collections.Generic;
using System.Web;

namespace TSharp.Core
{

    #region AppEventArgs

    /// <summary>
    /// 应用程序事件参数
    /// </summary>
    /// <author>
    /// tangjingbo
    /// </author>
    /// <remarks>
    /// tangjingbo at 2009-8-4 13:44
    /// </remarks>
    public class AppEventArgs : EventArgs
    {
        private readonly IDictionary<string, object> items = new Dictionary<string, object>();

        /// <summary>
        /// 事件上下文传递参数的列表
        /// </summary>
        public IDictionary<string, object> Items
        {
            get { return items; }
        }

        /// <summary>
        /// 是否中断后边的事件执行
        /// </summary>
        /// <value>
        ///   <c>true</c> if cancel; otherwise, <c>false</c>.
        /// </value>
        public bool Cancel { get; set; }

        /// <summary>
        /// 事件触发对象
        /// </summary>
        public Osgi.OsgiEngine Sender { get; set; }
    }

    #endregion

    #region IApplicationEvent

    /// <summary>
    /// 
    /// </summary>
    /// <author>
    /// tangjingbo
    /// </author>
    /// <remarks>
    /// tangj15 at 2012-5-4 13:14
    /// </remarks>
    public interface IAppHandler
    {
    }

    #endregion

    #region IApplicationStart

    /// <summary>
    /// 应用程序开始，等同于Application_Start(),实现类必须有public ctor
    /// </summary>
    /// <author>
    /// tangjingbo
    /// </author>
    /// <remarks>
    /// tangjingbo at 2009-8-4 12:32
    /// 
    /// </remarks>
    public interface IAppStartHandler : IAppHandler
    {
        /// <summary>
        /// web程序开始调用，等同于Application_Start()
        /// </summary>
        /// <param name="args">The <see cref="TSharp.Core.AppEventArgs"/> instance containing the event data.</param>
        void OnStart(AppEventArgs args);
    }

    #endregion

    #region IApplicationStop

    /// <summary>
    /// 应用程序停止,等同于Application_Stop(),实现类必须有public ctor
    /// </summary>
    /// <author>
    /// tangjingbo
    /// </author>
    /// <remarks>
    /// tangjingbo at 2009-8-4 12:33
    /// </remarks>
    public interface IAppStopHandler : IAppHandler
    {
        /// <summary>
        /// web程序停止时调用，等同于Application_Stop()
        /// </summary>
        /// <param name="args">The <see cref="TSharp.Core.AppEventArgs"/> instance containing the event data.</param>
        void OnStop(AppEventArgs args);
    }

    #endregion


}